<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="${contextPath}/admin/stylesheets/common.css?v=${sversion}" />
    <link rel="stylesheet" href="${contextPath}/admin/stylesheets/table.css?v=${sversion}" />
	<script type="text/javascript" src="${contextPath}/ext/jquery/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="${contextPath}/admin/ext/layer_v2/layer.js"></script>
    <script type="text/javascript" src="${contextPath}/ext/laydate/laydate.js"></script>
    <script type="text/javascript" src="${contextPath}/admin/ext/jquery/selectbox.js"></script>
    <script type="text/javascript" src="${contextPath}/admin/ext/zw/grid.js?v=${sversion}"></script>
    <script type="text/javascript" src="${contextPath}/admin/javascripts/tool.js?v=${sversion}"></script>
	<script type="text/javascript" src="${contextPath}/admin/javascripts/zcommon.js?v=${sversion}" basepath="${contextPath}" baseinit="ajaxCheckLogin"></script>
</head>
<body>
	<div class="place">
        <span class="label-span">位置：</span>
        <span>任务配置</span>
    </div>
    <div class="body-warp">
        <div class="panel filter-block">
            <form class="form-inline">
                <div class="form-group">
                    <a href="javascript:void(0);" class="btn" id="search-btn"><i class="iconfont">&#xe61b;</i>搜索</a>
                </div>
            </form>
        </div>
        <div class="panel table-tool-bar">
            <a class="btn" href="###" onclick="add()"><i class="add-btn iconfont">&#xe619;</i>新增</a>
        </div>
        <table class="table" id="table"></table>
    </div>
<script>
    var grid = {};
    $(function() {
        grid = $('#table').grid({
            store: {
				url: '${contextPath}/jobInfo/list'
            },
            tool: {
                pagingBar: true
            },
            columns: [
            <#-- 
            	align: 'left'
            -->
            {
                title:'任务名称',
                dataIndex:'name'
            },
            {
                title:'执行时间',
                dataIndex:'exec_time'
            },
            {
                title:'数据处理方式',
                dataIndex:'type',
                renderer:function(cd){
                    if(1==cd){
                        return '覆盖';
                    }else if(2==cd){
                        return '追加';
                    }else{
                        return '';
                    }
                }
            },
            {
                title:'是否开启',
                dataIndex:'state',
                renderer:function(cd){
                    if(1==cd){
                        return '<font color="green">是</font>';
                    }else{
                        return '否';
                    }
                }
            },
            {
                title: '操作',
                dataIndex: 'id',
                renderer: function(cellData, rowData){
                	var result = '';
                	result += '<div style="overflow:hidden;">';
                	result += '<a class="btn btn-primary" href="###" onclick="editItem(\''+cellData+'\');">编辑</a>\n';
                    result += '<a class="btn btn-danger" href="javascript:void(0);" onclick="removeItem('+cellData+');">删除</a>\n';
                    result += '</div>';
                	return result;
                }
            }]
        });
        
    });
        
    //添加
	function add(){
		var url = '${contextPath}/jobInfo/toadd';
        layer.open({
             type: 2,
                title: null,
                shadeClose: false,
                closeBtn:0,
                maxmin: false, //开启最大化最小化按钮
                area: ['100%', '100%'],
                content: url
        });
	}
	
	//编辑
	function editItem(id){
	    var url = '${contextPath}/jobInfo/tomodify?id='+id;
        layer.open({
             type: 2,
                title: null,
                shadeClose: false,
                closeBtn:0,
                maxmin: false, //开启最大化最小化按钮
                area: ['100%', '100%'],
                content: url
        });
	}

	//删除
    function removeItem(id){
       var post = {};
       post.id = id ;
       var url = '${contextPath}/jobInfo/delete';
       if(!confirm("确定删除吗？")) return false;
       $.post(url,post,function(data){
           if(data.s == 1){
               alert("删除成功");
               grid.refresh();
           }else{
               alert(data.d||"删除失败");
           }
       },"json");
    }
	
	$('#search-btn').click(function(){
    	var params = {};
    	grid.load(params);
    });
    <#-- 
    $('#searchKey').keydown(function(e){
		if(e.keyCode==13){
		   $('#search-btn').click();
		   return false;
		}
	});
    -->
</script>
</body>
</html>